#include <stdio.h>
void f(int m, int n) 
{
	int a[m];
    int *b ; 
    b=a;
    int i, c = 0, num = 0;
    for (i = 0; i < m; i++)
        a[i] = i + 1;
    while (c < m) 
	{
        if (*b > 0) 
		{
            num++;
            if (num == n) 
			{
                printf("%d,", *b);
                *b = 0;
                num = 0;
                c++;
            }
        }
        *b++ ;
        if (b == m+a)
        	b=a;
    }
}
int main() {
    int m, n;
    scanf("%d %d", &m, &n);
    f(m, n);
    return 0;
}
